package task

import (
	"go-task/common"
	"go-task/data"
	"go-task/domain/model"
	"net"
)

type RespTaskHandler struct {
}

func NewRespTaskHandler() *RespTaskHandler {
	return &RespTaskHandler{}
}

func (p *RespTaskHandler) Handler(s *TaskServer, conn net.Conn, msgData *data.MsgData) {
	var taskResp data.TaskRespData
	common.ParseJson(msgData.Data, &taskResp)
	s.log.Infof("taskResp:%+v", taskResp)
	// status: 1-success 2-fail
	var timeTaskHis model.TimeTaskHis
	err := timeTaskHis.UpdateHis(taskResp.TaskHisId, taskResp.TaskId, taskResp.Status)
	if err != nil {
		s.log.Infof("update task (taskId=%s taskHisId=%d) his error:%v", taskResp.TaskId, taskResp.TaskHisId, err)
	}
}
